# -*- coding: utf-8 -*-
# @Author: QX
# @File: day8_0081multi.py
import time

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.webdriver.common.multi_action import MultiAction
from appium.webdriver.common.touch_action import TouchAction

#com.autonavi.minimap/com.autonavi.map.activity.NewMapActivity
caps = {
    "platformName": "Android",
    "platformVersion": "12",
    "deviceName": "ba08213e",
    "automationName": 'UiAutomator2',
    "appPackage": "com.autonavi.minimap",
    "appActivity": "com.autonavi.map.activity.NewMapActivity",
    #"newCommandTimeout": 6,
    "onReset": True
}
driver = webdriver.Remote("http://127.0.0.1:4723", caps)
driver.implicitly_wait(10)
driver.activate_app("com.autonavi.minimap")
# 点击同意并继续
driver.find_element(AppiumBy.ID,'com.autonavi.minimap:id/agree').click()

time.sleep(4)
# 创建两个触摸事件
action1 = TouchAction(driver)
action2 = TouchAction(driver)
action1.press(x=500, y=600).move_to(x=500, y=1000).release()
action2.press(x=500, y=1400).move_to(x=500, y=1000).release()

# 创建MultiAction实例对象
multi_action = MultiAction(driver)
# 将触摸事件加入TouchAction对象
multi_action.add(action1, action2)
# 执行事件
multi_action.perform()